package com.spring.demo12.eg3;

import org.springframework.context.event.ApplicationEventMulticaster;
import org.springframework.context.event.SimpleApplicationEventMulticaster;

/**
 * @author vhans
 */
public class Test {
    // 优化eg2
    @org.junit.Test
    public void test() {
        //创建事件广播器
        ApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
        //注册事件监听器
        eventMulticaster.addApplicationListener(new SendEmailOnOrderCreateListener());
        //广播事件订单创建事件
        eventMulticaster.multicastEvent(new OrderCreateEvent(eventMulticaster, 1L));
    }
}
